import { PrismaClient } from "@prisma/client";

const globalForPrisma = global as unknown as {
  prisma: PrismaClient | undefined
}


export const prisma =
  // 配置热部署
  globalForPrisma.prisma ??
  new PrismaClient({
    log: ["query"]
  })

// 不是生成环境，从全局变量中获取
if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;